package io.github.talelin.latticy.model;

import io.github.talelin.latticy.dto.rule.chargeCondition.ChargeConditionUpdateDTO;
import io.github.talelin.latticy.dto.rule.chargeItem.ChargeConditionDTO;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
import org.springframework.beans.BeanUtils;

/**
 * @author generator@wulongbo
 * @since 2022-08-25
 */
@Data
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
@TableName("charge_condition")
@AllArgsConstructor
@NoArgsConstructor
public class ChargeConditionDO extends BaseModel {

    /**
     * 规则项id
     */
    private Integer chargeItemId;

    /**
     * 规则key id
     */
    private Integer ruleKeyId;

    /**
     * 模板key
     */
    private String ftlKey;

    /**
     * 运算符号 > < >= <= ==等
     */
    private String symbol;

    /**
     * 输入框的值或者下拉框的下标值
     */
    private Integer ruleValueId;

    /**
     * 逻辑运算符 && ||
     */
    private String logical;

    public ChargeConditionDO(ChargeConditionDTO dto, Integer chargeItemId) {
        BeanUtils.copyProperties(dto, this);
        this.chargeItemId = chargeItemId;
    }

    public ChargeConditionDO(ChargeConditionUpdateDTO dto, Integer chargeItemId) {
        BeanUtils.copyProperties(dto, this);
        this.chargeItemId = chargeItemId;
    }
}
